/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.lb.trac.service;

import com.lb.trac.dao.DAOService;
import com.lb.trac.pojo.Allegati;
import com.lb.trac.pojo.Evento;
import com.lb.trac.pojo.StoricoTicket;
import com.lb.trac.pojo.Tickets;
import com.lb.trac.util.TracSetupUtil;

/**
 *
 * @author edoardo
 */
public class ManageTicketService {

    private DAOService daoService;
    private TracSetupUtil tracSetupUtil;

    public Tickets insertNewTicket(Tickets target) {

//        TracSetupUtil.copyTicketViewOnHbmMirror(ticketView,target);
        daoService.insert(target);
        return target;

    }

    public DAOService getDaoService() {
        return daoService;
    }

    public void setDaoService(DAOService daoService) {
        this.daoService = daoService;
    }

    public TracSetupUtil getTracSetupUtil() {
        return tracSetupUtil;
    }

    public void setTracSetupUtil(TracSetupUtil tracSetupUtil) {
        this.tracSetupUtil = tracSetupUtil;
    }

    public StoricoTicket insertStoricoTck(StoricoTicket st) {
        daoService.insert(st);
//        st.setIdStorico(result);
        return st;
    }

    public StoricoTicket updateTicket(Tickets ticketView, StoricoTicket st) {
    	return updateTicket(ticketView, st, true);
    }
    
    public StoricoTicket updateTicket(Tickets t, StoricoTicket st,boolean insert) {
        daoService.update(t);
        if(insert){
        	daoService.insert(st);
    }else{
    	daoService.update(st);
    }
        return st;
    }

    public void insertEventoDaInviare(Evento evento) {
        daoService.insert(evento);
    }

    public void delete(Evento evento) {
        daoService.delete(evento);
    }

	public void insertAllegato(Allegati allegato) {
		daoService.insert(allegato);
		
	}

	public void updateAllegato(Allegati a) {
		daoService.update(a);
	}
}
